package org.hongqi.common.senpec.file.demo;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class DemoController {
    @GetMapping("/progress")
    public void getProgress(HttpServletResponse response) throws InterruptedException, IOException {

        response.setContentType("application/json;charset=UTF-8");
        response.setStatus(HttpServletResponse.SC_OK);
        response.getWriter().println(0);
        for (int i = 0; i < 100; i++) {
            Thread.sleep(2000);
            response.getWriter().write(i);
            response.getWriter().println(i);
            System.out.println(i);
        }

    }
}
